package com.wxg.jfinal.util;

import com.jfinal.plugin.activerecord.dialect.AnsiSqlDialect;
import com.jfinal.plugin.activerecord.dialect.Dialect;
import com.jfinal.plugin.activerecord.dialect.MysqlDialect;
import com.jfinal.plugin.activerecord.dialect.OracleDialect;
import com.jfinal.plugin.activerecord.dialect.PostgreSqlDialect;
import com.jfinal.plugin.activerecord.dialect.SqlServerDialect;
import com.jfinal.plugin.activerecord.dialect.Sqlite3Dialect;

public class JFinalDialect {

	public Dialect d(String strDialect){
		return getDialect(strDialect);
	}
	
	public Dialect getDialect(String strDialect){
		if("ansi".equalsIgnoreCase(strDialect)){
			return new AnsiSqlDialect();
		}else if("mysql".equalsIgnoreCase(strDialect)){
			return new MysqlDialect();
		}else if("oracle".equalsIgnoreCase(strDialect)){
			return new OracleDialect();
		}else if("postgre".equalsIgnoreCase(strDialect)){
			return new PostgreSqlDialect();
		}else if("sqlite".equalsIgnoreCase(strDialect)){
			return new Sqlite3Dialect();
		}else if("sqlserver".equalsIgnoreCase(strDialect)){
			return new SqlServerDialect();
		}else{
			return new MysqlDialect();
		}
	}
}
